package com.example.rabc;

import com.example.rabc.monitor.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;

/**
 * 主应用程序类
 */
@SpringBootApplication
@Import(MonitorConfig.class)
public class RabcApplication implements CommandLineRunner {

    @Autowired
    private MonitorEventBus monitorEventBus;

    @Autowired
    private LoggingProcessor loggingProcessor;

    @Autowired
    private MetricsAggregator metricsAggregator;

    @Autowired
    private AlertProcessor alertProcessor;

    @Autowired
    private StorageProcessor storageProcessor;

    public static void main(String[] args) {
        SpringApplication.run(RabcApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        // 注册所有监控观察者
        monitorEventBus.addObserver(loggingProcessor);
        monitorEventBus.addObserver(metricsAggregator);
        monitorEventBus.addObserver(alertProcessor);
        monitorEventBus.addObserver(storageProcessor);

        System.out.println("监控系统已初始化完成");
    }

}
